import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import {AuthService} from '../auth.service';
import {XAuth} from '../../shared/auth/x-auth';
import {User} from '../../shared/auth/user';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: [ './login.component.scss' ]
})
export class LoginComponent implements OnInit {
  private _xAuth: XAuth;
  private _user: User = new User();

  constructor(private router: Router, private authService: AuthService) { }

  ngOnInit() {
  }

  login(event) {
    event.preventDefault();
    this.authService.login(this._user).then(() => {
          if ( this.authService.xAuth.authorizationTokenValue != null ) {
            this.router.navigate(['/loan']);
          }
        });
  }

}
